Test Series - java script

Test Number 78/92

Q: What is the purpose of lazy loading?
A. Immediate loading is necessary
B. Loading under command
C. Immediate loading is not necessary
D. Loading after a definite interval
Solution: Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program’s operation if properly and appropriately used. Lazy loading is a kind of loading in which we don’t need our JavaScript code to be available as soon as the page loads.
Q: Where is the external JavaScript placed in the case of lazy loading?
A. After window.onload event
B. Before window.onload event
C. In the header tag
D. In the HTML tag
Solution: Lazy loading is a kind of loading in which we don’t need our JavaScript code to be available as soon as the page loads. When we don’t need our JavaScript code to be available as soon as the page loads, we can script-load our external JavaScript after the window.onload event.
Q: What are the parameters of the attachEvent function?
A. Function
B. Function, Event
C. Event, Function
D. Event
Solution: The addEventListener() method attaches an event handler to an element without overwriting existing event handlers. The attachEvent function accepts two parameters: the event to attach to, and the function to invoke when the event occurs.
Q: What is the result when the showPerformanceMetrics() is called before loading the remote script?
A. Throws an exception
B. Throws an error
C. It will load by itself
D. Throws an exception and It will load by itself
Solution: perflogger.showPerformanceMetrics() tells the user about the performance parameters of the script loading. If you try to make the call to perfLogger.showPerformanceMetrics() and the script hasn’t just loaded but also executed, then you will get an error.
Q: Which of the following is an attribute to the script object?
A. onclick
B. onload
C. onshow
D. onhover
Solution: The onload event occurs when an object has been loaded. The onload event occurs when an object has been loaded.
Q: Which is the method used to add an event listener?
A. addEventListener()
B. addListener()
C. addEvent(Listener)
D. addListener(Event)
Solution: The addEventListener() method attaches an event handler to the specified element. The addEventListener() method is used to add an event listener to the script.
Q: What is the purpose of the domLoading attribute?
A. Document exists
B. Document can load
C. Document has loaded
D. Document begins to load
Solution: domLoading is the time immediately before the user agent sets the current document readiness to ‘loading’. The domLoading attribute is used when the document begins to load.
Q: How is the render time calculated?
A. Date.Now()
B. Date.Now() – performance.timing.domLoading
C. performance.domLoading
D. Date.Now() – performance.domLoading
Solution: The rendering engine parses the HTML and the CSS and displays the parsed content on the screen. The render time is calculated as Date.Now() – performance.timing.domLoading.
Q: The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is _____________
A. Instance object
B. Constructor object
C. Destructor object
D. Prototype object
Solution: A prototype is an object that is associated with every functions and object by default in JavaScript, where function’s prototype property is accessible and modifiable and object’s prototype property (aka attribute) is not visible. The properties of the prototype object are inherited by all instances of the class, and properties whose values are functions behave like instance methods of the class.
Q: You can refresh the webpage in JavaScript by using ___________
A. window.reload
B. location.reload
C. window.refresh
D. page.refresh
Solution: The reload() method is used to reload the current document.The reload() method does the same as the reload button in your browser. One can refresh the webpage in JavaScript by using location.reload.

You Have Score    /10